<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="sealte.hvpms.pojo.*,sealte.hvpms.dao.impl.RulesDAOImpl,java.util.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>仓鼠网上投票系统HVPMS</title>
<link type="text/css" rel="stylesheet" href="css/rules_management.jsp.css" />
<script src="js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script language=javascript>
function deleteRule(id){
	if(confirm("确定删除该限制规则？")==true){
		$.post("AdminDeleteRule",{id:id},function callback(data){
			if(data=='"ok"'){
				alert("删除成功！");
				window.location.href="<%=basePath%>hvpms_admin/rules_management.jsp";
			}else if(data=='"fail"'){
				alert("删除失败！！");
			}
		});
	}
}
function sbar(st, col) {
	st.style.backgroundColor = '#EAF4FE';
}
function cbar(st) {
	st.style.backgroundColor = '';
}
</script>
</head>
<body>
<%
	Admin admin = (Admin)session.getAttribute("admin");
	if(admin!=null){
%>
<div id="num2">
	<h2><img src="images/page.png">&nbsp;限制规则管理--维护</h2>
</div>

<div id="num1">
<table>
	<tr>
		<th width="6%">序号</th><th>规则内容</th><th width="10%">是否可用</th><th width="20%">操作</th>
	</tr>
<%
		RulesDAOImpl rb = new RulesDAOImpl();
		List<Rule> all = rb.getAll();
		if(all!=null){
			Iterator<Rule> iter = all.iterator();
			String isUsed = null;
			String operations = null;
			String changeUsed = null;
			int i = 0;
			while(iter.hasNext()){
				Rule rule = iter.next();
				isUsed = (rule.getIsUsed().equals("N"))?"<img src=images/list_false_icon.gif>":"<img src=images/list_true_icon.gif>";
				changeUsed = (rule.getIsUsed().equals("N"))?"设为可用":"设为不可用";
				operations = "<a href=AdminChangeRuleIsUsed?id="+rule.getId()+"&isused="+rule.getIsUsed()+">"+changeUsed+"</a>&nbsp;|&nbsp;<a href=javascript:deleteRule("+rule.getId()+")>删除</a>";
				
%>
	<tr onmouseover=sbar(this) onmouseout=cbar(this)>
		<td><%=(++i) %></td>
		<td><%=rule.getContent() %></td>
		<td><%=isUsed %></td>
		<td><%=operations %></td>
	</tr>
<%
			}
		}else{
%>
		<tr><td colspan=4>暂时没有任何数据信息！</td></tr>	
<%
		}
	%>
</table>
</div>
<span>
		<%
			String message_ciu = (String)request.getAttribute("message_ciu");
			String message_delete = (String)request.getAttribute("message_delete");
			if(message_ciu!=null&&!message_ciu.equals("")){
				out.println("["+message_ciu+"]");
			}
			if(message_delete!=null&&!message_delete.equals("")){
				out.println("["+message_delete+"]");
			}
		%>
</span>
<%	
	}else{
		out.println("谢绝跨路径访问！");
	}
%>
</body>
</html>